<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-ctrInfo-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">订单编号：</label>
				<div class="col-sm-8">
					<input id="ctrSn" name="ctrSn" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">订单名称：</label>
				<div class="col-sm-8">
					<input id="ctrName" name="ctrName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">订单金额：</label>
				<div class="col-sm-8">
					<input id="ctrAmount" name="ctrAmount" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">订单电子版附件：</label>
				<div class="col-sm-8">
					<input id="ctrAtt" name="ctrAtt" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">总人月数：</label>
				<div class="col-sm-8">
					<input id="ctrWl" name="ctrWl" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">供应商主键：</label>
				<div class="col-sm-8">
					<input id="compId" name="compId" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">订单状态：</label>
				<div class="col-sm-8">
					<select id="ctrSta" class="form-control m-b" th:with="type=${@dict.getType('pm_ctr_status')}">
	                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	                </select>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "pm/ctrInfo";
		$("#form-ctrInfo-add").validate({
			rules:{
				ctrSn:{
					required:true,
				},
				ctrName:{
					required:true,
				},
				compId:{
					required:true,
				}
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	add();
	        }
	    }
		
		function add() {
        	var ctrSn = $("input[name='ctrSn']").val();
        	var ctrName = $("input[name='ctrName']").val();
        	var ctrAmount = $("input[name='ctrAmount']").val();
        	var ctrWl = $("input[name='ctrWl']").val();
        	var compId = $("input[name='compId']").val();
        	var ctrSta = $("#ctrSta option:selected").val();
        	$.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "pm/ctrInfo/add",
        		data : {
        			"ctrSn": ctrSn,
        			"ctrName": ctrName,
        			"ctrAmount": ctrAmount,
        			"ctrWl": ctrWl,
        			"compId": compId,
        			"ctrSta": ctrSta
        		},
        		async : true,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        			$.operate.saveSuccess(data);
        		}
        	});
        }
	</script>
</body>
</html>
